//抽象工厂模式：通过对类的工厂抽象使其业务用于对产品类簇的创建，而不负责穿件某一类的产品实例
//以汽车为例，创建一个抽象工厂
var AbstractFactory = function (subType,superType) {
    if(typeof AbstractFactory[superType]==='function'){

        function F() {}
        F.prototype = new  AbstractFactory[superType]()
        //改变指向
        subType.constructor = subType
        //子元素继承父类
        subType.prototype = new F()
    }else {
        throw new Error('不存在类')
    }
}
//定义汽车的基本属性
AbstractFactory.bus = function () {
    this.type = 'bus'
}
AbstractFactory.bus.prototype={
    getSpeed:function () {
        return new Error('抽象方法')
    },
    getPrice:function () {
        return new Error('抽象方法')
    }
}
var Benz = function (price,speed) {
    this.price = price
    this.speed = speed
}
AbstractFactory(Benz,'bus')
Benz.prototype.getSpeed = function () {
    console.log(this.speed)
}
Benz.prototype.getPrice=function () {
    console.log(this.price)
}

// var benz = new Benz('200','200')


